#[allow(unused_imports)] use std::{ptr::null_mut, sync::OnceLock};

use crate::framework::GameApp;

#[allow(static_mut_refs, non_snake_case)]
#[no_mangle]
pub extern "C" fn create_game(
    to_render: bool,
    with_window: bool,
    to_extract_game_info: bool,
) -> *mut GameApp {
    unsafe {
        static mut GAMEAPP: OnceLock<GameApp> = OnceLock::new();

        GAMEAPP.get_or_init(|| {
            GameApp::build(
                to_render,
                with_window,
                to_extract_game_info,
            )
        });

        GAMEAPP.get_mut().unwrap() as *mut GameApp
    }
}
